<?php
function deleteRecord($id)
{
	$sql = "DELETE FROM tbl_stocks WHERE id='$id'";
	$result = query($sql);	
	if($result)
	{
		errorMessage("Record deleted successful....!");
	}	
	else
	{
		errorMessage("Record delete error...!");
	}	
}
?>
<?php
	if(isset($_REQUEST["id"]))
{
	$id = $_REQUEST["id"];
	deleteRecord($id);
}
?>
<table class="bordered" width="770">
  <thead>
    <tr>
       <th colspan="3">View Stock information <div class="new_sale"><a href="index.php?page=add_stock&action=add_stock_new">New Stock</a></div></th>
    </tr> 
 </thead>
    <tr>
         <?php 
			if(@$errors!=""){
				echo " <td colspan=\"3\"><span class='red'>". @$errors."</span></td>";
			}else{
				if(isset($_REQUEST['msgStatus']))
					echo " <td colspan=\"3\"><span class='red'>". $_REQUEST['msgStatus'].@$_REQUEST['one']."</span></td>";
			 }
			?>
                           
    </tr>
</table>     
<div id="dt_example">
    <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
        <thead>
           <tr>
        	<th width="100">User</th>
            <th width="100">ID</th>
			<th width="100">Supplier</th>
            <th width="100">Date</th>
            <th width="100">product</th>
            <th width="100">QTY</th>
            <th width="100">B_Price</th>
            <th width="100">S_Price</th>
            <th width="100">Total</th>
            <th width="100">S_Open</th>
            <th width="100">S_Close</th>
			<th width="100">Action</th> 
      	   </tr>
        </thead>
        <tbody>
        <?php
			$sql="SELECT * FROM  tbl_stocks WHERE type='entry' ";	
			$result=query($sql);
			while($row = fetch_object($result))
			{
        ?>   
        		<tr>
                	<td width="100"><?php echo $row->user_name; ?></td>
                    <td width="100"><?php echo $row->stock_id; ?></td>
                    <td width="100"><?php echo $row->sup_name; ?></td>
                    <td width="100"><?php echo $row->pd_date; ?></td>
                    <td width="100"><?php echo $row->pd_name; ?></td>
                    <td width="100"><?php echo $row->qty; ?></td>
                    <td width="100"><?php echo $row->buying_price; ?></td>
                    <td width="100"><?php echo $row->selling_price; ?></td>
                    <td width="100"><?php echo $row->total; ?></td>
                    <td width="100"><?php echo $row->opening_stock	; ?></td>
                    <td width="100"><?php echo $row->closing_stock; ?></td>
                    <td width="100"> 
                        <a href="index.php?page=add_stock&action=add_stock_edit&stock_id=<?php echo $row->stock_id;?>"><img src="images/edit.png" border="0" alt="Edit"></a>
                        <a onclick="return confirm('Do you want to delete this record..?');" href="index.php?page=add_stock&action=add_stock&id=<?php echo $row->id;?>"><img src="images/delete.png" border="0" alt="delete"></a>
                    </td>
 				</tr>   
        <?php 
            }
        ?>
        </tbody>
    </table>
</div>
	 